package com.wangbo.basic.doubles;

public class DoubleLinkedListUtil {

    public static class Node{
        public int value;
        public Node pre;
        public Node next;

        public Node(int value) {
            this.value = value;
        }
    }

    /**
     * 反转链表
     */
    public static Node reverse(Node head) {
        Node next = null;
        Node newHead = null;

        while (head != null) {
            next = head.next;

            head.next=newHead;
            head.pre = next;

            newHead = head;
            head = next;
        }

        return newHead;
    }
}
